package org.wmq.travelagency02.common;

import lombok.extern.slf4j.Slf4j;
import org.wmq.travelagency02.helper.JwtLoginHelper;
import org.wmq.travelagency02.model.Entity.CacheUserInfo;

import java.util.Map;

public class UserContext {
    private static ThreadLocal<CacheUserInfo> userThreadLocal = new ThreadLocal<>();
    public static void setUser(CacheUserInfo cacheUserInfo){
        System.out.println("setUser:" + cacheUserInfo);
        userThreadLocal.set(cacheUserInfo);
    }
    public static CacheUserInfo getUser(){
        return userThreadLocal.get();
    }
    public static void removeUser(){
        userThreadLocal.remove();
    }

    public static Long getUserId(){
        return userThreadLocal.get().getId();
    }
    public static Byte getUserType(){
        return userThreadLocal.get().getUserType();
    }
}
